﻿<%@ WebHandler Language="C#"  Class="GovernmentOfficeProject.handler.SystemContactsDatafeed" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GovernmentOfficeProject.LevelDataAccessModel;
using GovernmentOfficeProject.SysTools;
using GovernmentOfficeProject.LevelBusinessLogic;
using System.Web.SessionState;

namespace GovernmentOfficeProject.handler
{
    /// <summary>
    /// SystemContactsDatafeed 的摘要说明
    /// </summary>
    public class SystemContactsDatafeed : IHttpHandler, IRequiresSessionState
    {
        public void ProcessRequest(HttpContext context)
        {
            //权限判断
            if (SystemContext.CurrentUserID == 0)
            {
                context.Response.Redirect("~/Login.htm?FromUrl=" + HttpUtility.UrlEncode(context.Request.Url.AbsoluteUri));
            }
            else
            {
                SystemContext.CurrentUserID = SystemContext.CurrentUserID;
            }
            context.Response.ContentType = "text/plain";
            string action = context.Request.Params["action"];
            string ret = "";
            switch (action)
            {
                case "list":ret =  getUserData(); break;
            }
            context.Response.Write(ret);
        }
        
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string getUserData()
        {
            HttpContext context = System.Web.HttpContext.Current;
            BLL_USER bllUser = new BLL_USER();
            int currentPage = Convert.ToInt16(context.Request.Params["page"]);
            int pageSize = Convert.ToInt16(context.Request.Params["rows"]);
            Entity_USER_User user = new Entity_USER_User();
            user.RealName = context.Request.Params["RealName"];
            user.MobilePhone = context.Request.Params["MobilePhone"];
            user.Telephony = context.Request.Params["Telephony"];
            user.RecordStatus = 1;
            Grid<Entity_USER_User> grid = bllUser.getUserGridData(user, currentPage, pageSize);
            return JsonHelper.ToJson(grid); ;
        }
        
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}